package com.xlh.enums.course;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

/**
 * 课程标识枚举
 * <p>
 * Created by lx on 2020/11/9.
 */
@Getter
@AllArgsConstructor
public enum CourseFlagEnum {

    CHAPTER_RESOURCES_FLAG(0, "章节显隐类型"),
    CHAPTER_CLIPBOARD_FLAG(1, "章节剪切板显隐类型"),
    COURSE_CLIPBOARD_FLAG(2, "课程剪切板显隐类型");

    private Integer code;

    private String message;

    public static CourseFlagEnum getByCode(Integer code) {
        for (CourseFlagEnum courseStatusEnum : CourseFlagEnum.values()) {
            if (Objects.equals(courseStatusEnum.getCode(), code)) {
                return courseStatusEnum;
            }
        }
        return null;
    }

    public static String getMessageByCode(Integer code) {
        CourseFlagEnum courseStatusEnum = getByCode(code);
        return courseStatusEnum == null ? null : courseStatusEnum.getMessage();
    }

}
